const fs = require('node:fs')
const fs2 = require('node:fs/promises')
const path = require('node:path')
fs.readFile('./index.txt', 'utf8', (err, data) => {
  if (err) throw err
  console.log(data.toString(),'readFile')
})
fs2.readFile('./index.txt').then((data) => {
  console.log(data.toString(),'readFilePromise')
}).catch((err) => {
  console.log(err)
})
const res=  fs.readFileSync('./index.txt')
console.log(res.toString(),'readFilesSync')

const readStream =fs.createReadStream('./index.txt')
readStream.on('data',(chunk)=>{
  console.log(chunk.toString(),'readStream')
})
readStream.on('end',()=>{
  console.log('end')
})
fs.mkdir(path.join('test/test1'),{recursive:true}, (err) => {
  console.log(err)
})
fs.watch('./index.txt',(event,filename)=>{
  console.log(event,filename)
})
// fs.rm(path.join('test'),{recursive:true}, (err) => {})